home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS Toolkit
/
BBS Toolkit.iso
/
rbbs_pc
/
r2dbf121.zip
/
2BYTEDAT.C
next >
Wrap
Text File
|
1991-02-18
|
2KB
|
63 lines
#include "i:\clipper\nandef.h"
#include "i:\clipper\extend.h"
#include "i:\tc\include\stdlib.h"
void NumEnter( char s[], int num1, int pos );
int mystrlen( char s[]);
CLIPPER TwoByte()
/* Convert a 2 byte to the data RBBS had for subscription and return
it in database DATE format, ie "19880101") */
{
unsigned char subdate[2];
char thedate[9] = " ";
div_t x;
int i, mo, da;
strcpy (subdate, _parc(1));
x = div( subdate[0] & ( 1 ^ 255) , 2);
i = x.quot + 1980;
x = div( subdate[1], 32);
mo = x.quot | ((subdate[0] & 1) * 8);
da = (subdate[1] & ( 224 ^ 255 ));
/*
i = (subdate[0] & ( ~ 1 ) ) / 2 + 1980;
mo = (subdate[1] / 32) | ((subdate[0] & 1) * 8);
da = (subdate[1] & ( ~ 224 ) );
*/
NumEnter( thedate, i, 0); /* put i in 1st position(0),eg. 1980 */
NumEnter( thedate, mo, 4); /* put mo in 5th position(4),eg. 01 */
NumEnter( thedate, da, 6); /* put da in 7th position(6),eg. 31 */
_retds( thedate );
}
void NumEnter( char s[], int num1, int pos )
/*
Convert the passed number to a string and
place in Clipper Date String
*/
{
char temp[10];
int i,l;
itoa(num1, temp,10); /* int->string, radix=10 */
l = mystrlen(temp);
if (l == 1)
{
s[pos] = '0';
pos++;
}
for (i=0;temp[i]!='\0';i++) /* put into s[] */
s[pos+i] = temp[i];
return;
}
int mystrlen( char s[] )
{
int i = 0;
while (s[i] != '\0') i++;
return (i);
}